package com.itheima.health.controller;

import com.itheima.health.dto.MobileCodeDTO;
import com.itheima.health.entity.Result;
import com.itheima.health.service.MobileValidateCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录控制器
 */
@RestController
@RequestMapping("/mobile/login")
@Slf4j
@Api(tags = "手机端登录接口")
public class MobileLoginController {
    @Autowired
    private MobileValidateCodeService mobileValidateCodeService;

    /**
     * 验证码登录
     * @param dto
     * @return
     */
    @PostMapping("/smsLogin")
    @ApiOperation("验证码登录")
    public Result smsLogin(@RequestBody MobileCodeDTO dto){
        log.info("登录数据：{}", dto);
        Boolean flag = mobileValidateCodeService.veriyf(dto);
        if (flag){
            return Result.success();
        }else {
            return Result.error();
        }
    }
}
